<template>
  <div class="content">
    <img
      src="http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/banner.png"
      alt=""
      class="banner"
    />
    <div class="title">
      <p>近期热门</p>
      <span>更多 &gt;</span>
    </div>
    <div class="hot">
      <div class="hot-c" v-for="item in hot" :key="item.id">
        <img :src="item.img" alt="" />
        <p>{{ item.title }}</p>
        <div class="doctor">
          <img :src="item.doctor.img" alt="" />
          <span>{{ item.doctor.name }}</span>
          <span>{{ item.doctor.job }}</span>
        </div>
      </div>
    </div>
    <div class="title">
      <p>可回看</p>
    </div>
    <van-tabs class="lookback">
      <van-tab v-for="item in lookBack" :title="item.title" :key="item.id">
        <div v-for="val in item.msg" :key="val.id" class="lookback-c">
          <img :src="val.img" alt="" />
          <p>{{ val.title }}</p>
          <div class="doctor">
            <img :src="val.doctor.img" alt="" />
            <span>{{ val.doctor.name }}</span>
            <span>{{ val.doctor.job }}</span>
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { ref, onMounted } from "vue";

import { getNewApi } from "../../../utils/api";

export default {
  setup() {
    const hot = ref([
      {
        id: 1,
        img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/hot.png",
        title: "好“孕”来|如何正确应对生育难题？",
        doctor: {
          name: "江雪娟",
          job: "主任医师",
          img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/doctor.png",
        },
      },
      {
        id: 2,
        img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/hot.png",
        title: "好“孕”来|如何正确应对生育难题？",
        doctor: {
          name: "江雪娟",
          job: "主任医师",
          img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/doctor.png",
        },
      },
      {
        id: 3,
        img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/hot.png",
        title: "好“孕”来|如何正确应对生育难题？",
        doctor: {
          name: "江雪娟",
          job: "主任医师",
          img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/doctor.png",
        },
      },
      {
        id: 4,
        img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/hot.png",
        title: "好“孕”来|如何正确应对生育难题？",
        doctor: {
          name: "江雪娟",
          job: "主任医师",
          img: "http://qvxb53t4o.hd-bkt.clouddn.com/broadcast/doctor.png",
        },
      },
    ]);

    const lookBack = ref([]);

    const getLookBack = async () => {
      const res = await getNewApi();
      lookBack.value = res.result[0].live;
    };

    onMounted(() => {
      getLookBack();
    });

    return {
      hot,
      lookBack,
      getLookBack,
    };
  },
};
</script>

<style lang="less" scoped>
.content {
  padding: 0 14px;
  overflow: auto;
  position: fixed;
  top: 98px;
  left: 0;
  right: 0;
  bottom: 50px;

  .banner {
    width: 100%;
    margin-top: 13px;
  }

  .title {
    display: flex;
    justify-content: space-between;
    align-items: center;

    p {
      font-size: 23px;
      color: #333;
      font-weight: 700;
    }

    span {
      font-size: 13px;
      color: #999;
    }
  }

  .hot {
    display: flex;
    height: 185px;
    overflow: auto;

    .hot-c {
      margin-right: 10px;

      > img {
        width: 234px;
        height: 131px;
      }

      p {
        font-size: 13px;
        color: #333;
        margin: 4px 0;
      }

      .doctor {
        display: flex;
        align-items: center;
        > img {
          width: 22px;
          height: 22px;
        }

        span {
          font-size: 12px;
          color: #999;
          margin-left: 4px;
        }
      }
    }
  }

  /deep/ .van-tab {
    height: 32px;
    background-color: #f8f9fd;
    border-radius: 16px;
    padding: 0 10px;
    margin-right: 5px;
    flex-wrap: wrap;
  }
  /deep/ .van-tab--active {
    background-color: #eff8ff;
  }
  /deep/ .van-tabs__line {
    display: none;
  }
  /deep/ .van-tab__pane {
    display: flex;
    flex-wrap: wrap;
  }

  .lookback {
    .lookback-c {
      width: 50%;

      img {
        width: 168px;
        height: 94px;
      }
      p {
        margin: 0;
        font-size: 14px;
        color: #333;
        font-weight: 700;
      }
      .doctor {
        display: flex;
        align-items: center;
        > img {
          width: 22px;
          height: 22px;
        }

        span {
          font-size: 12px;
          color: #999;
          margin-left: 4px;
        }
      }
    }
  }
}
</style>
